package charts; 

import charts.series.dots.Scat;
import charts.series.Element;
import charts.series.dots.DotFactory;
import string.Utils;
import flash.geom.Point;
import flash.display.Sprite;
import charts.series.dots.DefaultDotProperties;
import charts.Structs.DotStyleStruct;

class ScatterBase<StyleType, ValueType> extends Base<ValueType> {
	var style:StyleType;
	
	var default_style:DefaultDotProperties;

	var line_width:Int;
	var colour:String;
	var key:String;
	var font_size:Int;
	var values:Array<ValueType>; // TODO - figure out what the actual type is going to be, instead of Dynamic

	
	public function new() {super();}
	
	//
	// called from the base object
	//
	override function get_element( index:Float, value:Dynamic ): ValueType {
		// we ignore the X value (index) passed to us,
		// the user has provided their own x value
		
		var default_style:StyleType = {
			dot_size:		this.style.dot_size,
			halo_size:		this.style.halo_size,
			width:			this.style.width,	// stroke
			colour:			this.style.colour,
			tip:			this.style.tip
		};
		
		// Apply dot style defined at the plot level
		Object_helper.merge_2( this.style.dot_style, default_style ); // TODO - figure out why I need this.
		// Apply attributes defined at the value level
		Object_helper.merge_2( value, default_style );
			
		// our parent colour is a number, but
		// we may have our own colour:
		if( Std.is( default_style.colour, String) )
			default_style.colour = Utils.get_colour( default_style.colour );
		
		var props:Properties = new Properties( value, this.default_style); // TODO - also figure out why I need this
			
		return DotFactory.make( index, props );
		
		// return DotFactory.make( 0, new Properties( { } ));// default_style );
	}
	
	// Draw Points...
	public override function resize( sc:ScreenCoordsBase ): Void {
		
		var spr:Sprite;
		for ( i in 0...this.numChildren) {
			spr = cast( this.getChildAt(i), Sprite);
			
			//
			// filter out the line masks
			//
			if( Std.is( spr, Element) )
			{
				var e:Element = cast( spr, Element);
				e.resize( sc );
			}
		}
	}

}
